Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Minor bugfixes and code optimization #49

Merged
merged 10 commits into from
Jul 2, 2014

Conversation

alray
Copy link
Contributor

@alray alray commented Jun 25, 2014

I tested this in IE 6-8 (native), IE6-10 (compatibility mode), Firefox 2.0, Opera 9.52 and everything seems to work

Merge with original repository
This change implements next features:
1) Deal with "access is denied" error in IE 7/8 if script is using in local files (demo example doesn't work in IE 7/8, only IE6). Thanks to CSSUtilities plugin (http://www.brothercake.com/scripts/cssutilities) for information inside source code
2) Code optimization: using ActiveXObject instead of XMLHttpRequest for IE 7/8 allowed to skip browser check and use closure without "new" keyword which is equal to all other browsers
3) getXMLHttpRequest was highly optimized and moved to xhr() method due its small size
@alray
Copy link
Contributor Author

alray commented Jun 25, 2014

Only after commit I found that problem with "new" keyword for onreadystatechange() closure in IE 6/7 was fixed because I moved onreadystatechange() declaration before send() (what is logically correct) and not because I used ActiveXObject for IE 7/8 (which isn't connect with IE6). So in case when onreadystatechange() is initializing before using (sending request) "new" keyword is not required for old versions of IE. Tests confirm this

RegExp is using for removing comments now. This works faster (~5-15%) and needs less code
@alray
Copy link
Contributor Author

alray commented Jun 26, 2014

I think I found tool which You are using for minification. Is this a UglifyJS 2 (http://gpbmike.github.io/refresh-sf/)?

1) Fixed unused and duplicating variables in xhr() arguments
2) Code was minified (unnecessary function and condition were removed)
3) Code style fixes
@alray alray changed the title Changes in xhr() function Minor bugfixes and code optimization Jun 26, 2014
@chuckcarpenter
Copy link
Owner

@alray I'm using Uglify via Grunt. This runs a jshint and creates the minified version for me. You can install all that via NPM.

@chuckcarpenter
Copy link
Owner

Commits loaded via another branch e.g., 91b7f63

Also, I bumped the version for release along w/ using the built in minification via Grunt. Thanks @alray

@alray
Copy link
Contributor Author

alray commented Jul 1, 2014

But you didn't merge all my changes. There is also 774196f commit with several code optimizations

alray@774196f

@chuckcarpenter chuckcarpenter reopened this Jul 1, 2014
@chuckcarpenter
Copy link
Owner

You are correct, I didn't realized you pushed more commits after I'd already pulled down the branch for testing. Please update your pull request from master so I can test/merge again.

@chuckcarpenter
Copy link
Owner

Side note, could you please install/use GruntJS to run the grunt task that will lint and build the final file?

@@ -56,7 +52,7 @@
},

matchCSS = function ( sheetCSS, link ) { // collect all of the rules from the xhr response texts and match them to a pattern
var clean = removeComments( removeMediaQueries(sheetCSS) ),
var clean = removeMediaQueries( sheetCSS ).replace(/\/\*[\s\S]*?\*\//g, ''), // remove MediaQueries and comments
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice optimization! :)

@chuckcarpenter chuckcarpenter merged commit 9f36d2f into chuckcarpenter:master Jul 2, 2014
chuckcarpenter added a commit that referenced this pull request Jul 2, 2014
@chuckcarpenter
Copy link
Owner

@alray, figured out how to get these in and rerun the build. Will bump the version and release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants