Why split the [removed] tag when writing it with [removed]()?

前端 未结 5 1183
挽巷
挽巷 2020-11-21 07:37

Why do some sites (or advertisers that give clients javascript code) employ a technique of splitting the tags

5条回答
  •  眼角桃花
    2020-11-21 08:14

    The solution Bobince posted works perfectly for me. I wanted to offer an alternative method as well for future visitors:

    if (typeof(jQuery) == 'undefined') {
        (function() {
            var sct = document.createElement('script');
            sct.src = ('https:' == document.location.protocol ? 'https' : 'http') +
              '://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js';
            sct.type = 'text/javascript';
            sct.async = 'true';
            var domel = document.getElementsByTagName('script')[0];
            domel.parentNode.insertBefore(sct, domel);
        })();
    }
    

    In this example, I've included a conditional load for jQuery to demonstrate use case. Hope that's useful for someone!

提交回复
热议问题