-
-
Save gorobey/e5a87878461659d736e48eb45f15f5ac to your computer and use it in GitHub Desktop.
Defer Inline Javascript
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
| // With $script variable | |
| $(document).ready(function() { | |
| $('script[type="text/javascript/defer"]').each(function() { | |
| var $script = $('<script type="text/javascript"/>').text($(this).clone().text()); | |
| $(this).after($script).remove(); | |
| }); | |
| }); | |
| // Without $script variable | |
| $(document).ready(function() { | |
| $('script[type="text/javascript/defer"]').each(function() { | |
| $(this).after($('<script type="text/javascript"/>').text($(this).clone().text())).remove(); | |
| }); | |
| }); | |
| // Minified | |
| $(document).ready(function(){$('script[type="text/javascript/defer"]').each(function(){$(this).after($('<script type="text/javascript"/>').text($(this).clone().text())).remove()})}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment