By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript calling jQuery and Migrate these days


Active Coder

I am upgrading an older site that was using jQuery 1.8.3 and am bumping jQuery to 1.12.4 and using the 1.4.1 migrate plugin for the time being. I see that jQuery had been called the following way

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>window.jQuery || document.write('<script src="<?php bloginfo('template_url'); ?>/assets/scripts/vendor/jquery-1.12.4.min.js"><\/script>')</script>

and am wondering if that is still necessary these days, and if I should do something similar for

<script src="https://code.jquery.com/jquery-migrate-1.4.1.min.js"></script>

Is that just so if the CDN is down it calls it from the local server? Do people do this still?
and yes this should load jquerry locally
but loading data externally only makes sense when you have thousands of visitors daily, local is otherwise faster

I wouldn't work with jquerry at all anymore, it's an "outdated" huge collection.
Even bootstrap has thrown out jquerry.
Do people just use straight JS these days? Should I not bother calling it from the external URL and just get rid of that extra check? I probably don't have thousands of visitors daily to this site.
Nice, ok, I am running Migrate and it has picked up a couple of deprecated errors. Wondering if anyone might have input how to update.

1. JQMIGRATE: jQuery.fn.load() is deprecated

jQuery(window).load(function () {

and then

2. JQMIGRATE: jQuery.browser is deprecated

Specifically it is calling these 3 lines...
$.browser.msie && !d && (function() {

})(jQuery, this);

Here is the entire script for context... wondering if it is related to msie if there is a simple way to just chop all that out of the script since nobody cares what this looks like on that old of a browser? It was just some #hash script to work with Isotope filtering some categories so you could link to a specific category. Still needed, but not for some old IE browser.

/*! hashchange event v1.3 (c) Ben Alman. MIT/GPL License. <benalman.com/projects/jquery-hashchange-plugin/> */
(function($, e, b) {
    var c = "hashchange",
        h = document,
        g = $.event.special,
        i = h.documentMode,
        d = "on" + c in e && (i === b || i > 7);
    function a(j) {
        j = j || location.href;
        return "#" + j.replace(/^[^#]*#?(.*)$/, "$1")
    $.fn[c] = function(j) {
        return j ? this.bind(c, j) : this.trigger(c)
    $.fn[c].delay = 50;
    g[c] = $.extend(g[c], {
        setup: function() {
            if (d) {
                return false
        teardown: function() {
            if (d) {
                return false
    f = (function() {
        var j = {},
            m = a(),
            k = function(q) {
                return q
            l = k,
            o = k;
        j.start = function() {
            p || n()
        j.stop = function() {
            p && clearTimeout(p);
            p = b
        function n() {
            var r = a(),
                q = o(m);
            if (r !== m) {
                l(m = r, q);
            } else {
                if (q !== m) {
                    location.href = location.href.replace(/#.*/, "") + q
            p = setTimeout(n, $.fn[c].delay)
        $.browser.msie && !d && (function() {
            var q,
            j.start = function() {
                if (!q) {
                    r = $.fn[c].src;
                    r = r && r + a();
                    q = $('<iframe tabindex="-1" title="empty"/>').hide().one("load", function() {
                        r || l(a());
                    }).attr("src", r || "javascript:0").insertAfter("body")[0].contentWindow;
                    h.onpropertychange = function() {
                        try {
                            if (event.propertyName === "title") {
                                q.document.title = h.title
                        } catch (s) {}
            j.stop = k;
            o = function() {
                return a(q.location.href)
            l = function(v, s) {
                var u = q.document,
                    t = $.fn[c].domain;
                if (v !== s) {
                    u.title = h.title;
                    t && u.write('<script>document.domain="' + t + '"<\/script>');
                    q.location.hash = v
        return j
})(jQuery, this);

Buy us a coffee!

Top Bottom