Home   Developing   -   Bootstrap   Q&A   Issues   References   Notes   History   Attic  

Goto previous pageGoto parent pageGoto next page
Page 3 of 9

Blocco Notes Logo

Daftari Home - Developing

Under the Hood
or: JavaScript Bootstrap

This chapter is for the technically curious only. It is about the detailled ongoings when the JavaScript is loaded into the browser. Read the code here: daftari.js.

General Description

See how the HTML page is prepared in chapter Installation.

JavaScript in the page manipulates the DOM. The HTML injection into the page's DOM goes straight forward over an onload eventhandler in the body tag of the page. This initial onload provides the little infrastructure e.g. forms now hidden.

id="id20111227o1822" Loading a page involves about the following steps:

Below a description of each single step.

Pullscriptsbehind

If the JavaScript code is departed in several script files, it is convenient, if only one of them must be enrolled as a script tag in the page, and the other scripts are pulled behind by that first one.

Sorrily I found it complicated to make this feature trustfully running. After becoming tired debugging in this area, and wanting just make it applicable somehow, I decided to merge all code into one file to get around of this topic until later. Of course the Pullscritpsbehind feature's code is still present, and can be called somehow to work on it if wanted.

When to run the pull behind code? There are two moments, one can attempt to pull scripts behind:

(1) During script load time. This is the first idea, if this works, the scripts would be available immediately. But as it didn't work (always), I thought, the problem may be, that at this time, the DOM is just not yet ready so far, that additional script elements can be attatched to the header.

(2) During the onload event handling. This time seems more save than during script load time. The DOM is complete, and attatching script tags to the header should be certainly possible.

...

The body onload event

The onload event is the time when you are sure, the DOM is ready.

(1) The Pull-scripts-behind feature (if activated)

(2) Paint the Daftari icon on the page.

(3) See for a slideshow to be run on the page.

...

Perhaps make a slideshow run.

The Daftari and the Slideshow are incopatible so far, only one of the two can be on the same page.

...

What/why/how Pull-Scripts-Behind?

Pull-Scripts-Behind is typically located in the boostrapping module, but we treat it as an own feature, since it shall be applicable from any situation ... (if working at all)

The Pull-Scripts-Behind feature is (temporarily) abandoned. The workaround is, that we merged all necessary scripts into one big file daftari.js. If perhaps one day Pull-Scripts-Behind will work, we shall split this big file again into it's smaller modules.

Why is the Pullscriptsbehind feature wanted at all? In other projects, they don't do such thing. The official way to have several scripts is, to load them from the HTML page's script tags. We want have only one line in the HTML page to integrate Daftari. If you have many HTML files e.g. serveral thousands, spread over about 20 sites, then it is no fun to go to all of them, just if some JavaScript detail constellation has changed.