PDA

View Full Version : How can i split js file



fvinson
28 Aug 2012, 2:13 AM
I have 1 js file with


Ext.Loader.setConfig({enabled: true});
Ext.Loader.setPath('Ext.ux', '../javascript/extjs-4.1.1/examples/ux');
Ext.require([
]);
Ext.onReady(function() {
Ext.QuickTips.init();
....PART1.....
....PART2.....
)};

I create 3 js files with a part of Instructions
file1.js with PART1
file2.js with PART2
file3.js with :


Ext.Loader.setConfig({enabled: true});
Ext.Loader.setPath('Ext.ux', '../javascript/extjs-4.1.1/examples/ux');
Ext.require([
]);
Ext.onReady(function() {
Ext.QuickTips.init();
)};


In html i put <script>... file1.js</script>
<script>... file2.js</script>
<script>... file3.js</script>

in file1.js i create a gridPanel with a checkcolumn xtype and doest not work
when i put all in 1 file all work

Thanks

mixo
28 Aug 2012, 2:20 AM
What exactly you put into parts 1-3?

if it's your defined components you can include it over Ext.require and load just before create your objects.

also you can do some checks in your browser console to understand is your files load successful

Zdeno
28 Aug 2012, 2:31 AM
If you do that on server side when you have any scripting language, you can join multiple files this way. E.g. with PHP:



...
Ext.onReady(function() {
Ext.QuickTips.init();
<?php
echo file_get_contents('file1.js');
echo file_get_contents('file2.js');
?>
)};
...


I dont think this is good way. But you can minimize files before you join them.