[webkit-gtk] Proper way to load javascript

Daniel Berek berekdaniel at gmail.com
Sun Mar 3 00:04:03 PST 2019

Hi, I am using gtkmm-3.0 and the new webkit2gtk-4.0 (where the javascript
is running on a new web process).
I have two problems to solve, which connecting together.
1. At first, I am not sure whats the proper way to load an external
javascript file. In this version of webkit, the <script
src="script.js"></script> tag from html file doesnt work, even the html
cant be loaded.
So I have to read the 'script.js' manually, and after
each webkit_web_view_load_html() I have to
execute webkit_web_view_run_javascript().
Is there a more sophisticated method to load external javascript? ex
loading once, so all html sites could use it?
2. I have a webview widget (described at the end of this message) and I
periodically called its destructor ( default destructor) to get rid off the
cached data and made a new instance. Unfortunately, deleting the webview
widget leaks almost 400kB of memory. So I stopped calling its destructor,
which is perfectly fine for me (no more leaks, I cant even see the
increasing cache) but after a few javascript execution, my functions in the
external 'script.js' file doesnt work properly, athough
the run_javascript_finished_discard_result() doesnt show any error.
 It seems, the javascript process cant handle that much executions.
Somebody knows whats the proper way for deleting a webview widget
Or any help is appreciated.
 I hope I was clear, and we could find a solution. Thanks, Daniel

class CWebView : public Gtk::Widget

: Gtk::Widget(webkit_web_view_new())
g_signal_connect(*this, "load-changed", G_CALLBACK(web_view_load_changed),
WebKitUserContentManager *manager =
ButtonPressed_Event = NULL;
virtual ~CWebView()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-gtk/attachments/20190303/8bf86459/attachment.html>

More information about the webkit-gtk mailing list