Code Monkey home page Code Monkey logo

Comments (9)

emirotin avatar emirotin commented on May 22, 2024 1

Was about to suggest the similar optimization. Plucking methods like document.createElement into the variables at the top of the module (like const __createElement = document.createElement.bind(document)) will help the minifier when the components have many nodes.

from svelte.

chrisdavies avatar chrisdavies commented on May 22, 2024 1

Yup. I did a little test locally yesterday, and found about a 20% savings by doing this on a relatively small project.

from svelte.

Rich-Harris avatar Rich-Harris commented on May 22, 2024

We should definitely do this. As a starting point, helpers like createElement and detachElement would reduce the size a bit (gzip notwithstanding) and could be externalised if necessary. I hadn't thought of custom factories though, that's an interesting idea.

from svelte.

Ryuno-Ki avatar Ryuno-Ki commented on May 22, 2024

cloneNode could be helpful here, too.

from svelte.

emirotin avatar emirotin commented on May 22, 2024

BTW does it make sense to have elementWithClass actually compatible with React.createElement which is (name, attributes, children)?
Who knows if it will provide some positive side-effect like JSX compatibility?

from svelte.

trueadm avatar trueadm commented on May 22, 2024

@emirotin you want to avoid polymorphic functions like that, that's why Inferno avoids them in core – they result in functions that can't be properly optimised.

from svelte.

emirotin avatar emirotin commented on May 22, 2024

Interesting @trueadm thanks for the insight.

from svelte.

PaulBGD avatar PaulBGD commented on May 22, 2024

Helpers have been in Svelte for a while, is this issue open for other helpers? Like the suggested elementWithClass and potentially similar ones like elementWithId?

from svelte.

Rich-Harris avatar Rich-Harris commented on May 22, 2024

Probably slightly trickier to do elementWithClass in Svelte's current form, because creating nodes and adding attributes happens in two separate places (so that hydration can work). So maybe we should close this and revisit it if we ever need to eke out a few extra microseconds 😀

from svelte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.