I created an extension containing .svg files in a similar way to the Wisej extensions as for the FontAwesome that WiseJ provides.
I created a DatagridView with two columns of image type.
In the first I put the .svg image of a padlock and in the second the .svg image of a fax machine both assigning the ImageSource with the path in our resource library (ex: resource.wx/DG.Ext.Font/fax.svg)
When finished loading the table with the corresponding images, press F12 in the browser, and analyzing the html produced, I see that EVERY SINGLE image is rendered by injecting into a <div> tag via the “style” a “background-image:url(“data:image/svg+ …”)”
where “…” a fairly long sequence of base64 characters describing the svg.
But in the second column, the .svg image is background-image:url(“resource.wx/DG.Ext.Font/fax.svg”), there is only
the path in the resource file (as I would have also expected for the image in the first column).
Why can’t you always use path rather than inline entry, this doesn’t result in as much wasted space on the page and in the browser’s memory?
In theory, the browser uses less cache memory if it refers to a path rather than the same long and cumbersome character stream.
What am I doing wrong? is there a way to have the resource path used rather than the inline stream?
Best regards
Tiziano
Ciao Tiziano, here is the explanation.
What you see with the base64 image is the local javascript image cache implemented in Wisej client side components. There is also a bit more complexity to this related to using images in cells because cells in a datagrid are not components, they don’t exists as javascript components since they are rendered on demand when scrolling. So:
But:
Additionally, looking at the sample:
Your sample could be
dataGridView1.Rows.Add(row1);
dataGridView1.Rows.Add(row2);
dataGridView1[0, 0].Value = “resource.wx/Wisej.Ext.MaterialDesign/android-logo.svg?color=#fca326”;
dataGridView1[0, 1].Value = “resource.wx/Wisej.Ext.MaterialDesign/android-logo.svg”;
Or
dataGridView1.SetValue(0, 0, “resource.wx/Wisej.Ext.MaterialDesign/android-logo.svg?color=#fca326”);
dataGridView1.SetValue(0, 1, “resource.wx/Wisej.Ext.MaterialDesign/android-logo.svg”);
Using SetValue() prevents the forced creation of a row when the grid is data bound.
HTH
First of all, thank you for your help.
I attach the project, and I think I understand one more detail.
In the project I load a DataGridView with two rows. The first column will contain the images whose render of our discussion.
The first row has an image with the color changed ( directive ?color=#…).
“resource.wx/DG.Ext.Font/lock.svg?color=#fca326”
The second row has a natural unmanipulated svg image (black)
“resource.wx/DG.Ext.Font/fax.svg”
It appears that color modification excludes from simple cashing.
In fact, by pressing F12 and hovering over the respective images, the first one is inline with many fonts, the second one has been downloaded to the browser’s source folder.
In fact, going to “Sources” and expanding the folders in the subfolder of “localhost:5000” > “resource.wx > DG.Ext.Font” we find the image of the second row of the table “fax.svg” (see the attachment Screenshot.png)
I wanted to ask you if you think the problem doesn’t exist, so should I ignore the inline of the first immegine because the browser will take care of it or should I pose the problem in pages where colored .svg’s are used to save having to load them in the resource file.
Bests Regards
Tiziano
We don’t produce any HTML. The html you see is Chrome’s representation of the DOM. Base64 sources are used routinely by our local image caching system and improve performance by a lot. Wisej doesn’t assemble or concatenate HTML, it uses dom elements directly (through a shadow fast dom system). When you inspect the HTML chrome rebuilds the HTML representation. Otherwise our HTML is simply the empty Default.html page.
Can you attach a small runnable sample project so we can give you a better explanation on why the URL is used in one case and why the base64 is embedded in another?
Please login first to submit.