Created
August 26, 2014 07:06
-
-
Save sTiLL-iLL/cdfac6c407283147edf4 to your computer and use it in GitHub Desktop.
basic conditional loading (loads when specified elements are present)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The arguments against this practice will be (1) concatenating into existing JS and CSS to save on the number of requests and (2) flash of content style changes. The first argument needs to be judged on a per-case basis; if the required CSS and JS is small, it should be concatenated to a file used throughout the site or site subsection. The second argument can always be hushed with a bit of transition magic! | |
*/ | |
$('article pre').length && (function() { | |
var mediaPath = '/assets/'; | |
$('<link>').attr({ | |
type: 'text/css', | |
rel: 'stylesheet', | |
href: mediaPath + 'css/syntax.css' | |
}).appendTo(document.head); | |
var syntaxScript = document.createElement('script'); | |
syntaxScript.async = 'true'; | |
syntaxScript.src = mediaPath + 'js/syntax.js'; | |
doc.body.appendChild(syntaxScript); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment