Minification issue

11 views
Skip to first unread message

nico

unread,
Apr 30, 2011, 1:43:26 PM4/30/11
to phonegap
Hello !

I experienced a weird behavior with minified code and I wonder how to
solve this.

On my app, in one of my page I have a list of items with a title, a
subtitle, a description and a picture (background image in the div). I
get the content of the list from a webservice (I can't store the
content on the client side because content changes) each time the user
goes on the page. The webservice is called on the animation start
event (pageAnimationStart in jQTouch). The server side works well and
is fast. I get each time the whole result (I can see it with a
console.log). However, sometimes the list is displayed with empty
items whereas the data is loaded (the background image which is the
good one). It's like I have no data or I cannot access the DOM.
To be more precise. To made my list :
- I clear the old list.
- I clone my model <li> DOM element that is in my index.html and using
jquery .clone() method.
- Then I fill the new elem using .html('str') method.
- And I finally append the new element to the destination <ul>
element.

All worked very well when I was testing on device with non minified
code. But since I minified the code I have this issue I don't know how
to solve. To minify my code I use yuicompressor in basic mode (strip
all comments and unecessary spaces, no obfuscation or other code
modification).

So my questions are :
- Does anybody has already experienced the same problem or / and has
an idea how to solve it ?
- Does minification really improve performance and reduce launching /
loading time (I gained approximatively 100 ko on my project with js
minification )?
- Should I also minify my css files ?

Thanks for your help

nico

Samuel M

unread,
May 1, 2011, 3:20:33 PM5/1/11
to phonegap
Hi Nico,

It looks like the .html bug (nothing to do with minification) :
http://blog.johnmckerrell.com/2007/03/07/problems-with-safari-and-innerhtml/
Don't use the .html('str') method, it's buggy on iOS

And yes, minification is useful

Hope this help,

Sam

nico

unread,
May 2, 2011, 4:25:39 AM5/2/11
to phonegap
Thanks for you help !

I went further in my investigations. I discovered that the problem
appears when I try to set the list while jQTouch animation is still in
progress. Consequently I modify my callback in order to check if the
animation is in progress or not. If it is, I bind the pageAnimationEnd
event on the jqt div, execute my callback when the event is triggered
and then unbind my event. It seems to work pretty well.

But it seems weird the problem only appeared after minification (I
didn't have it before and the app with non minified code was tested
several on 10 devices). Maybe the minified code is a bit faster.

nico

On 1 mai, 21:20, Samuel M <samuel.miche...@gmail.com> wrote:
> Hi Nico,
>
> It looks like the .html bug (nothing to do with minification) :http://blog.johnmckerrell.com/2007/03/07/problems-with-safari-and-inn...
Reply all
Reply to author
Forward
0 new messages