Inject jQuery into Any Webpage

Even MVVM framework is more and more popular in the web front developments, but the strength of jQuery cannot be replaceable. Sometimes, we need the jQuery's useful APIs to achieve some complex actions, but many webpages give up jQuery, so some skills is needed to inject the jQuery into the webpages which had abandon the jQuery library.

I find a good solution and share it, here is the code:

if(!window.jQuery){
  var script = document.createElement('script');
  script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js";
  script.type = 'text/javascript';
  document.getElementsByTagName('head')[0].appendChild(script);
}

Just copy the code into the Chrome Devloper tool, and the jQuery would be loaded into the webpage :-)

 标签: jQuery, 前端开发

作者  :  sailor

仅仅看明白了还不够,能把别人给讲明白了才算及格。


  1. 说的很好,就是英文看起来有点吃力

    October 20th, 2016 at 04:15 pm 回复


最新文章