Comments (10)
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.
I am fine with multiple builds.
from imscjs.
@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.
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 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.
@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)
- For .. in loops not protected from iterating prototype properties HOT 14
- Upgrade to use es6 language features? HOT 1
- `Set()` has a name clash with the ES6 `Set` object HOT 1
- Multiple referenced generic font family names can result in duplicate font-family values
- Error parsing fontSize with two lengths HOT 2
- Improve performance with a large number of regions and ISDs
- Unable to specify rgba color values for tts:textShadow HOT 1
- elementBoundingRect needs to be declared a `var`
- Update timeBase attribute to accept full list of values HOT 6
- adjacent tts:textCombine spans are combined into a single span HOT 3
- HTML rb, rtc and rbc elements are deprecated HOT 2
- if a line starts/ends with a ruby definition, line padding is not applied
- SMPTE timecode parsed incorrectly (23.976 FPS) HOT 1
- Resolve images source while generating ISD HOT 18
- Spaces in `tts:fontFamily` list not handled in HTMLStylingMapDefinition code HOT 1
- Firefox bug with negative margins HOT 1
- FontFamily `default` name mapping missing HOT 7
- fillLineGap doesn't always fill the gap HOT 12
- Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'imscISD') HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imscjs.