Amir
Amir

Reputation: 862

How can I split Jquery.js file into multiple file?

I have a web server that files must be smaller than 64KB and I have a lot of dependency to jquery and I can't use other library such as zepto. the jquery minified size is 95Kb and i want split jquery into two files. how can i split this file into two files?

NB. I have to use atleast v1.9 or later for my project and the server does not support gzip.

Upvotes: 0

Views: 568

Answers (2)

Amir
Amir

Reputation: 862

Every thing is possible !

    <script type="text/javascript">
        var client = new XMLHttpRequest();
        client.open('GET', '/js/jq1.js',false);
        client.onload = function() {
        var jq1 = client.responseText;
        client.open('GET', '/js/jq2.js',false);
        client.onload = function() {
        var jq2 = client.responseText;
        var scriptTag = document.createElement("script");
        scriptTag.type = "text/javascript";
        scriptTag.innerHTML = jq1+jq2;
        scriptTag.async = false;
        ( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( scriptTag );
}
client.send();
}
client.send();
        </script>

Upvotes: 3

Rafi Ud Daula Refat
Rafi Ud Daula Refat

Reputation: 2257

In this case i would select an older version of jQuery. here you will find the file size of various versions of Jquery as you can not use CDN. minified 1.3.2v is less that 64KB it think.

https://mathiasbynens.be/demo/jquery-size

Upvotes: 2

Related Questions