Coder Social home page Coder Social logo

Comments (11)

philwolstenholme avatar philwolstenholme commented on May 25, 2024 1

An option to exclude the Array.from() polyfill (polyfills/array.from.js) could reduce the size a bit too, for users who are already loading a polyfill for this feature, or for users who only support browsers with native support for Array.from()

I think I've seen other libraries do this by providing a library.min.js file without the extras, and a library.all.min.js with the extras bundled in.

from goodshare.js.

koddr avatar koddr commented on May 25, 2024

@tracker1 @philwolstenholme fix 6.0.0, thanks for support!

from goodshare.js.

tracker1 avatar tracker1 commented on May 25, 2024

@koddr would still add closure[1], to see how small you can get it, 38kb is still very large for what this library does. Another possibility would be conditional builds, so only the social networks desired are actually built. Like one with top (facebook, twitter, instagram, pinterest), and another with all.

Alternatively a plugin structure, so that each social network is a separate add-in that can be joined into a single script after the fact, or loaded adjacently.

[1] https://github.com/ampproject/rollup-plugin-closure-compiler

from goodshare.js.

koddr avatar koddr commented on May 25, 2024

@tracker1 hm.. rollup-plugin-closure-compiler does similar 38kb.. what's principle different between him and rollup-plugin-uglify (what I use in 6.0.0)?

from goodshare.js.

tracker1 avatar tracker1 commented on May 25, 2024

If you can use the ADVANCED option for closure, it should gain you some size...

from goodshare.js.

koddr avatar koddr commented on May 25, 2024

And one more.. how do you want to cut Babel from build? I use class and other ES6+ code, I have no idea how I may cut this JS compiler. Can you help me?

from goodshare.js.

koddr avatar koddr commented on May 25, 2024

@tracker1

If you can use the ADVANCED option for closure, it should gain you some size...

So, I use it:

...
compiler({
  compilation_level: "ADVANCED"
})
...

Output size is 34 857 bytes (~35 kb). Profit is ~3 kb. Okay.

from goodshare.js.

tracker1 avatar tracker1 commented on May 25, 2024

class syntax would be hard without babel... you'd have to convert everything to prototype based inheritance modelling, which may not be worth it... though you may gain more by setting the minimum browser for your @babel/preset-env to IE9 or IE11 (depending on where you want to cut) as it is, it's generating transforms and using fills you don't actually need.

from goodshare.js.

tracker1 avatar tracker1 commented on May 25, 2024
{
  "presets": [
    [
      "@babel/preset-env",
      {
        "targets": {
           "ie": 9,
          "esmodules": true
        },
        "useBuiltIns": "usage",
        "loose": true
      }
    ]
  ]
}

from goodshare.js.

tracker1 avatar tracker1 commented on May 25, 2024

You shouldn't need the separate Array.from polyfill, the above should give it to you as-needed.

from goodshare.js.

koddr avatar koddr commented on May 25, 2024

@tracker1 I switched back compilation_level to "SIMPLE" and delete "loose": true, because it's totally broke my bundle. You may see errors at 6.0.3 version.

Now, goodshare.js is back to 38 Kb and... it's better, than not working bundle!

from goodshare.js.

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.