Do not load unnecessary script files (#4193)
parent
87b96f8d33
commit
9008ab3407
@ -0,0 +1,7 @@ |
||||
export default function ready(loaded) { |
||||
if (['interactive', 'complete'].includes(document.readyState)) { |
||||
loaded(); |
||||
} else { |
||||
document.addEventListener('DOMContentLoaded', loaded); |
||||
} |
||||
} |
@ -0,0 +1,24 @@ |
||||
import TimelineContainer from '../mastodon/containers/timeline_container'; |
||||
import React from 'react'; |
||||
import ReactDOM from 'react-dom'; |
||||
import loadPolyfills from '../mastodon/load_polyfills'; |
||||
import ready from '../mastodon/ready'; |
||||
|
||||
require.context('../images/', true); |
||||
|
||||
function loaded() { |
||||
const mountNode = document.getElementById('mastodon-timeline'); |
||||
|
||||
if (mountNode !== null) { |
||||
const props = JSON.parse(mountNode.getAttribute('data-props')); |
||||
ReactDOM.render(<TimelineContainer {...props} />, mountNode); |
||||
} |
||||
} |
||||
|
||||
function main() { |
||||
ready(loaded); |
||||
} |
||||
|
||||
loadPolyfills().then(main).catch(error => { |
||||
console.error(error); |
||||
}); |
Loading…
Reference in new issue