Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Splitting long text for Template

by jcb (Parson)
on Feb 08, 2021 at 03:20 UTC ( [id://11128046]=note: print w/replies, xml ) Need Help??


in reply to Splitting long text for Template

Actually, using client-side JavaScript to replace the long text blocks with expand buttons and shorter text (as other monks have suggested) is the best way to handle this, because that will also gracefully degrade if the user blocks JavaScript, presenting all information, but in a less-convenient format.

Client-side JS code can also query the available display area and set CSS properties to hide only text as needed to accommodate some minimal number of records initially displayed at once. (You can collapse records at points chosen to ensure that N records will initially fit in the user's viewport, regardless of platform, but you will need to also handle the case where the viewport is too small to accommodate N records as further graceful degradation. You can test this by simply resizing a browser window to a small size and viewing the site.)

NoScript and similar extensions are commonly used as security measures because all or nearly all recent browser exploits have depended on JavaScript to function. I for one have a general policy of simply leaving sites that do not render with JavaScript disabled.

Replies are listed 'Best First'.
Re^2: Splitting long text for Template
by LanX (Saint) on Feb 08, 2021 at 03:52 UTC
    > because that will also gracefully degrade if the user blocks JavaScript

    He could split the text into two span-tags on the server and deliver them. Activated JS could than hide the second portion. This would limit the necessary JS logic to a minimum.

    I'm not sure anymore if there is a possibility for server side detection of JS in the HTTP headers, worst case would be a JS-triggered redirect to another path.

    > I for one have a general policy of simply leaving sites that do not render with JavaScript disabled.

    I have a contrary view, JS is disabled by default in my browsers and I tend to ignore blank sites. That's why I prefer minimal "static" functionality with optional JS add-ons. YMMV.

    But yeah, how to handle (no) JS was not part of the MVC concepts, and still causing the biggest headache.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11128046]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found