Returning JSON for Custom Touchbar widget

UPDATE.

I used the following to check my code: Change button background color if...

This does work. I converted this to my code and the moment I change the location of the icon to the website-location of the icon it stops working.

So I am a step further. I will keep this discussion up to date for others with identical problems.

tell application "Google Chrome"
set i to 1 as integer
set j to 15 #length of button
set activeColor to "128,128,128,255"
set normalColor to "220,220,220,175"

set tabName to (get title of tab i of (first window whose index is 1))
set stringLength to length of tabName

set tabIcon to execute of tab i of (first window whose index is 1) javascript "document.head.querySelector('link[rel~=icon]').href;"
#set tabIcon to "https://web.whatsapp.com/img/f01_78cd893586564a736b94f919cd2851f7.png"

if stringLength < j then
	set titleName to tabName as string
else
	set titleName to (characters 1 thru (j - 3) of tabName as string) & "..."
	#set titleName to titleName & "..."
end if

set activeTabIndex to active tab index of (first window whose index is 1) as integer
if activeTabIndex = i then
	set titleString to "\"text\":\"" & titleName & "\""
	#set iconString to "\"icon_path\":\"~/Desktop/battery/bCharging.png\""
	set iconString to "\"icon_path\":\"" & tabIcon & "\""
	set fontColor to "\"font_color\":\"255,255,255,255\""
	set backgroundColor to "\"background_color\": \"" & activeColor & "\""
	return "{" & titleString & "," & backgroundColor & "," & fontColor & "," & iconString & "}"
	#set tempString to "{\"text\":\"" & titleName & "\", \"background_color\": \"" & activeColor & "\", \"font_color\": \"255,255,255,255\", \"icon_data\": \"base64_icon_data\", \"icon_path\":\"" & tabIcon & "\"}"
else
	return "{\"text\":\"" & titleName & "\", \"background_color\": \"" & normalColor & "\", \"font_color\": \"0,0,0,0\"}"
end if

#return tempString
#return "{\"text\":\"Temp\", \"background_color\": \"255,85,100,255\", \"font_color\": \"100,200,100,255\",  \"font_size\": 10, \"icon_path\":\"" & tabIcon & "\",}"
	
end tell

EDIT: downloading the icon from the link and using it with same pathway as in the example works. So the icon itself is not the problem. Conclusion: The problem is with the icon-link directly to a web-address.