Skip to content

Try to reuse div creation #2405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
markelog opened this issue Jun 17, 2015 · 5 comments
Closed

Try to reuse div creation #2405

markelog opened this issue Jun 17, 2015 · 5 comments

Comments

@markelog
Copy link
Member

div = document.createElement( "div" ) construction used in many places, we can try to modulize it

@mr21
Copy link
Contributor

mr21 commented Jul 29, 2015

Hi @markelog :)

if by "modulize it" you think about doing that:

define([
    "../var/document"
], function( document ) {
function createElement( nodeName ) {
    return document.createElement( nodeName );
}
return createElement;
});

It's save -15 bytes by removing all the 16 occurences of document.createElement in the code.

   raw     gz Sizes
255862  75752 dist/jquery.js
 84426  29376 dist/jquery.min.js

   raw     gz Compared to master @ 5fe76c663f8a4986af62edb434a1708c006d0b21
   -32    +15 dist/jquery.js
  -125    -15 dist/jquery.min.js

If you want I can make a PR with this: https://gist.github.com/Mr21/81a1c21e0cbf7136245a

@mgol
Copy link
Member

mgol commented Jul 29, 2015

@mr21 I believe it was more about re-using the test div itself, i.e.:

define([
    "../var/document"
], function( document ) {
return document.createElement( "div" );
});

& similar for other types of test nodes that are created. If it helps with size, a separate createElement function could be created as well, I'd guess it won't save size, though (but feel free to check).

Please don't do anything for compat, though, before #2504 lands as it will change some test-related things.

@markelog
Copy link
Member Author

I believe it was more about re-using the test div itself

Yep

@timmywil
Copy link
Member

Closing in favor of tracking in the Roadmap.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
@mgol
Copy link
Member

mgol commented Jan 17, 2020

Not relevant anymore as master has almost no feature tests.

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

No branches or pull requests

4 participants