PDA

View Full Version : What is the role of bootstrap.js?



abcoa
16 Oct 2012, 2:52 PM
I have been trying to get SenchaCmd working on my project and am trying to understand the role of the bootstrap.js file...Documentation specifies that:

This file will give the framework the same level of "awareness" of your application code that it has of the framework code itself.

What? :)

Is this file only to be used during development in order to enable dynamic loading (Ext.Loader)?
Should this file be ignored when compiling for production?
Please elaborate!

Thanks

mitchellsimoens
23 Oct 2012, 7:35 AM
All it does is creates a <script> tag and sets up the framework file to use. Look at the source, it's an easy way to switch between dev and prod based on the location and the query string

abcoa
23 Oct 2012, 7:39 AM
I was referring to bootstrap.js generated by SenchaCmd not the one that comes with Ext JS.
What you describe in your reply is bootstrap.js that comes with Ext JS distro I believe...

mitchellsimoens
23 Oct 2012, 7:44 AM
I see, that is just the class name mapping to the actual file for framework files as well as setting up the alternate class name mappings.

abcoa
23 Oct 2012, 7:49 AM
Mitchell

I don't mean to be rude but have you even read my original post and the questions in it?
I appreciate all the help you and others provide but sometimes I feel posts are being replied to just for the sake of having replies.....

mitchellsimoens
23 Oct 2012, 8:12 AM
Answered the title. You don't need to really deal with it, Cmd will not have it when you build as it shouldn't be needed.

abcoa
23 Oct 2012, 8:31 AM
Answered the title. You don't need to really deal with it, Cmd will not have it when you build as it shouldn't be needed.

"Cmd will not have it when you build" - I am not sure what you mean by that....
When you use "sencha generate app" the bootstrap.js is generated, and when you issue "sencha app refresh" it is rebuilt....Try it...

mitchellsimoens
23 Oct 2012, 8:39 AM
meaning when you do a build, bootstrap.js won't be used

dongryphon
25 Oct 2012, 12:09 AM
I have been trying to get SenchaCmd working on my project and am trying to understand the role of the bootstrap.js file...Documentation specifies that:

This file will give the framework the same level of "awareness" of your application code that it has of the framework code itself.

What? :)

Is this file only to be used during development in order to enable dynamic loading (Ext.Loader)?
Should this file be ignored when compiling for production?
Please elaborate!

Thanks

The generated "bootstrap.js" file (as opposed to the one in the SDK) contains metadata for the dynamic loader. Things like aliases, alternate class names and file paths. This means that you won't need to use Loader.setPath anymore when using this feature.

The file is included in the generated HTML file like so:



<!-- <x-compile> -->
<!-- <x-bootstrap> -->
<script src="ext/ext-debug.js" type="text/javascript"></script>
<script src="bootstrap.js"></script>
<!-- </x-bootstrap> -->

<script src="js/app.js" type="text/javascript"></script>
<!-- </x-compile> -->


The compiler will replace the x-compile section with the script tag for all-classes.js but it ignores the x-bootstrap section when producing that file. So basically the bootstrap data is ignored in a build.

Clear as mud? :)

dongryphon
25 Oct 2012, 12:12 AM
You can refresh the bootstrap file using "sencha app refresh" by the way... since that metadata can become stale. That is handled automatically during builds, so the refresh is only needed for dev mode.

You can decide if you want to commit bootstrap.js to source control or ignore it. Most folks will commit it I suspect despite its non-source nature.