Skip to content
This repository has been archived by the owner on Apr 25, 2021. It is now read-only.

dropdown.js is slow #5

Open
milahu opened this issue Dec 8, 2018 · 1 comment
Open

dropdown.js is slow #5

milahu opened this issue Dec 8, 2018 · 1 comment

Comments

@milahu
Copy link

milahu commented Dec 8, 2018

dear Vanilla-Semantic-UI, please keep up the fight for better performance

this is a copy-paste from Semantic-UI issue 6703

Semantic-UI should run faster. jQuery is slow. prefer native JS

Expected Result

run faster

Actual Result

running slow : P

Version

2.4.2

Desc

this concerns the abuse of jQuery.

when i see code like ...

              module.debug('Creating entire dropdown from select');
              $module = $('<div />')
                .attr('class', $input.attr('class') )
                .addClass(className.selection)
                .addClass(className.dropdown)
                .html( templates.dropdown(selectValues) )
                .insertBefore($input)
              ;

in src/definitions/modules/dropdown.js line 360

... i suspect: this cant be fast.

and its not:

etc ...

templates.dropdown is fast, cos it only concats strings
in src/definitions/modules/dropdown.js line 3900

references

https://ilikekillnerds.com/2015/02/stop-writing-slow-javascript/

@milahu
Copy link
Author

milahu commented Dec 8, 2018

templates.dropdown is fast, cos it only concats strings

quote from jQuery forums

If string concatenation is the bottleneck in this calculation than you should try storing the string parts in an array and than join them using join().
This has proven to be much faster than "normal" string concatenation.

funny, in my chrome v70 browser, concat with 'x = x + substr' is faster by factor 1.5.
also push is faster than assign.

but im still puzzled, why jQuery.html is so slow ... maybe cos the context is XHTML?

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

No branches or pull requests

1 participant