Giter Site home page Giter Site logo

ESM version for modern browsers about ga-lite HOT 10 CLOSED

jehna avatar jehna commented on September 25, 2024
ESM version for modern browsers

from ga-lite.

Comments (10)

datapolitical avatar datapolitical commented on September 25, 2024 1

I would love to. But I wouldn’t have the first clue where to start.

from ga-lite.

jehna avatar jehna commented on September 25, 2024 1

@carlmjohnson Thank you for noticing! Should be fixed now with 08a96bb and fixed version 2.1.4 should be available from npm now

from ga-lite.

jehna avatar jehna commented on September 25, 2024

@datapolitical you could circumvent this issue by using the ga-lite from npm and bundling it yourself to an ESM version. And I certainly accept pull requests if you'd like to configure the webpack config in this repository 👍

from ga-lite.

jehna avatar jehna commented on September 25, 2024

In theory you could also point the <script type="module"> to the src/ga-lite.js and it should work just fine. The only issue is, that it does not expose a global ga-lite instance (like IMO the ESM should work in the first place). So you would have to have something like:

<script type="module">
import galite from 'path/to/galite/src/ga-lite.js';

galite('create', 'UA-XXXXXXXX-X', 'auto');
galite('send', 'pageview');
</script>

It does get much more complicated if you are tracking more than just page views, but in that case you probably want to separate ESM/es5 versions from your own code too

from ga-lite.

Gonzo2O28 avatar Gonzo2O28 commented on September 25, 2024

Any news or suggestions in how to fix this?

from ga-lite.

Gonzo2O28 avatar Gonzo2O28 commented on September 25, 2024

Babel fails to load "array.from" plugin. But it loads "@babel/plugin-transform-classes".
i also loaded it via npm, but i have also no clue where to start.
Would be nice to have a modern version which passes pagespeed insights.

Any help advise would be very nice!
Thank you!

from ga-lite.

Gonzo2O28 avatar Gonzo2O28 commented on September 25, 2024

nevermind, i found a better solution for me:

https://gist.github.com/mesaavukatlik/9280e6d665b5762ea187b5451c3db538

from ga-lite.

jehna avatar jehna commented on September 25, 2024

Nice, thank you for sharing! I'll add that to the readme of ga-lite 👍

from ga-lite.

earthboundkid avatar earthboundkid commented on September 25, 2024

I had been doing import galite from "ga-lite/src/ga-lite.js";, but it is broken now because ga-lite/src/commands is not included in the NPM bundle.

from ga-lite.

earthboundkid avatar earthboundkid commented on September 25, 2024

Fast, thanks.

from ga-lite.

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.