javascript - safely restyling a page with jQuery has ugly load apperance -
so have website i've styled , made functional css in case users unable use javascript. thing make further style changes jquery , append external stylesheet 'head'.
now page loads, style changes can seen split second makes page jittery (since style changes big). not want users seeing jittery load , suggestions on can hide page/provide smooth transition if jquery responds later (slow connection) during style changes.
any feedback appreciated! : )
one way solve problem not add css via javascript, instead include css link. stylesheet targeting devices javascript enabled, prepend body class gets added javascript. this:
javascript stylesheet
body.js header { display: block; } body.js footer { display: block; } body.js .my_jsmenu { display: block; } body.js .etc { display: block; }
markup
<head> <!-- normal stylesheets --> <link href="styles.css" type="text/css" rel="stylesheet" /> <!-- js stylesheet --> <link href="myjs_styles.css" type="text/css" rel="stylesheet" /> </head> <body> <script type="text/javascript"> document.body.classname += ' js'; </script>
you can use html tag lot of other engines such modernizr do. if using less or sass css process simplified, if aren't can little tedious.
personally, avoid these javascript disabled solutions. has javascript disabled @ point has intentionally disabled , knows aren't going proper experience. used have in 2000s, i'd somewhere around 2011 wasn't worth taking consideration.
as jquery adjusting styles, please make sure css covers initial load. can use jquery adjust based on user interaction or device resizing/scrolling/viewstate, site going dinged in seo if doesn't render until after javascript done running. checkout google page speed insights proper analysis of ux , it's loading configuration more details on that.
Comments
Post a Comment