Load all jquery material if javascript condition is met

I would like to check if there are more than large images on my php-generated forum page, and only if so, then I would like to download jquery and make some jquerystuff.

How can I dynamically load a library only if the condition is successful?

0
javascript jquery lazy-loading
source share
1 answer
(function() { if (something) { var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(s); } }()); 
+1
source share

All Articles