javascript - Using .no-js class for detection of js -


i have used method of having class of .no-js on <html> tag, using modernizr strips tag , replaces js if javascript enabled in user's browser.

basically, have built css3 mobile , desktop navigation. have styles change behaviour if there css transitions etc (checked modernizr) if there js or no-js.

the problem is, flash of no-js version before javascript has had time load , change class js. (because default class no-js)

what can't head around how find fix this. if place js specific code main classes, specify prefix .no-js flashes no-js if js enabled. if switch over, same...

maybe being stupid, pointers great.

paul irish has excellent blog post on dealing problem. here's solution post:

<!doctype html> <html lang='en' class='no-js'>     <head>         <script>(function(h){h.classname=h.classname.replace(/\bno-js\b/,'js')})(document.documentelement)</script>         ... 

the key make sure you've updated classnames prior browser having chance render anything.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -