I was able to load the flutter_pdf_render deferred by using
import 'package:pdf_render/pdf_render_widgets.dart' deferred as pdf;
But the main problem which delays the initial load time is the section inside the index.html
<script
src="https://cdn.jsdelivr.net/npm/pdfjs-dist@2.12.313/build/pdf.js"
type="text/javascript"
></script>
<script type="text/javascript">
pdfjsLib.GlobalWorkerOptions.workerSrc =
"https://cdn.jsdelivr.net/npm/pdfjs-dist@2.12.313/build/pdf.worker.min.js";
pdfRenderOptions = {
// where cmaps are downloaded from
cMapUrl: "https://cdn.jsdelivr.net/npm/pdfjs-dist@2.12.313/cmaps/",
// The cmaps are compressed in the case
cMapPacked: true,
// any other options for pdfjsLib.getDocument.
// params: {}
};
</script>
Is it possible to load the javascript files also async from dart?
Similar to the following template section
import 'dart:async';
import 'dart:html';
Future<void> loadJavascriptFile() async {
// Create a ScriptElement
var jsScript = new ScriptElement();
jsScript.src = 'path/to/javascript/file.js';
// Wait for the load event to complete
await jsScript.onLoad.first;
// Call a function from the loaded JavaScript file
context['myFunction'].callMethod('apply', [context, ['arg1', 'arg2']]);
}
void main() async {
// Call the async function to load the JavaScript file
await loadJavascriptFile();
}
Thank you for your help in advance and this would be a great achievement to reduce the initial loading time.
I was able to load the flutter_pdf_render deferred by using
import 'package:pdf_render/pdf_render_widgets.dart' deferred as pdf;
But the main problem which delays the initial load time is the section inside the index.html
Is it possible to load the javascript files also async from dart?
Similar to the following template section
Thank you for your help in advance and this would be a great achievement to reduce the initial loading time.