GithubHelp home page GithubHelp logo

Comments (10)

gkatsev avatar gkatsev commented on July 3, 2024 1

xmldom is only one suggestion. Any other suitable project is fine. This would likely involve creating two build outputs. One to be used by browsers and one by node.
For example, with mpd-parser, we import xmldom https://github.com/videojs/mpd-parser/blob/56eee17cfbdfbbbdb03c443776b4033405c5448a/src/stringToMpdXml.js#L1

import {DOMParser} from '@xmldom/xmldom';

And in the rollup config, for the "globals" build, we have @xmldom/xmldom return window https://github.com/videojs/mpd-parser/blob/56eee17cfbdfbbbdb03c443776b4033405c5448a/scripts/rollup.config.js#L36

    defaults.browser['@xmldom/xmldom'] = 'window';

Unless we wanted to do dynamic code loading, there's probably no way to handle this without multiple builds.

from imscjs.

palemieux avatar palemieux commented on July 3, 2024 1

I am fine with multiple builds.

from imscjs.

bbert avatar bbert commented on July 3, 2024

@dsilhavy any opinion?
If it can reduce the bundle size, it can help, even if sax minified bundle is quite small.

FYI, in dash.js the metadataHandler in fromXML() is used: https://github.com/Dash-Industry-Forum/dash.js/blob/54612bb541c43cb7ce900f0c49111999ff817ae2/src/streaming/utils/TTMLParser.js#L130

from imscjs.

gkatsev avatar gkatsev commented on July 3, 2024

The sax parser is almost a 3rd of the minified-gzipped size of this project (checked via bundlephobia.com).

In another project, I've used https://github.com/xmldom/xmldom for doing the parsing in node and then in the bundle for browsers, it rewrites the import to be return window, since xmldom returns an object with a DOMParser property on it.

While I do think that worrying about a few kb here and there isn't a big deal when you're going to be streaming large video files, it's still helpful to reduce filesize when and where we can, particularly for code that ships to the client side. This seems like a good candidate to help reduce the bundled size of the project.

from imscjs.

nigelmegitt avatar nigelmegitt commented on July 3, 2024

@nigelmegitt any strong feelings?

From the documentation for xmldom:

xmldom has an own SAX parser implementation to do the actual parsing

I suspect that changing sax.js for xmldom would likely increase the parsing duration and the minified size, though I haven't checked. Maybe it needs a "spike" experiment.

Another XML parser that could be worth considering is fast-xml-parser, though again, I haven't tried it. It appears to support all the required features, but again, I haven't looked at the size.

If there is a library that uses the native parser when available, and can be compiled into both a "native" and a "not native" variant where the native one has a lower size and hopefully better performance, then I'm all in favour.

from imscjs.

bbert avatar bbert commented on July 3, 2024

@nigelmegitt any strong feelings?

From the documentation for xmldom:

xmldom has an own SAX parser implementation to do the actual parsing

I suspect that changing sax.js for xmldom would likely increase the parsing duration and the minified size, though I haven't checked. Maybe it needs a "spike" experiment.

Another XML parser that could be worth considering is fast-xml-parser, though again, I haven't tried it. It appears to support all the required features, but again, I haven't looked at the size.

If there is a library that uses the native parser when available, and can be compiled into both a "native" and a "not native" variant where the native one has a lower size and hopefully better performance, then I'm all in favour.

Another XML parser to consider that claims to be faster than fast-xml-parser and with very smal bundle size: tXml.

This tXml parser is included in next dash.js v5 for MPD parsing.

from imscjs.

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.